package com.dgut.domain;

import java.sql.*;

public class JDBCDemo {

    public static void main(String[] args) throws ClassNotFoundException, SQLException {

        Class.forName("com.mysql.cj.jdbc.Driver");
        Connection conn=DriverManager.getConnection("jdbc:mysql://localhost:3306/mybatis?serverTimezone=UTC","root","123");
        String sql="select * from user where id = ?";
        PreparedStatement preparedStatement=conn.prepareStatement(sql);
        preparedStatement.setInt(1,41);
        ResultSet rs=preparedStatement.executeQuery();
        while(rs.next())
        {
            System.out.println(rs.getString("username")+"--->"+rs.getString(3));
        }
        rs.close();
        preparedStatement.close();
        conn.close();
    }
}
